/*
 * NavigationMixin.fx
 *
 * Created on 10-jun-2009, 14:32:00
 */

package fotoboek.controls;


import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;


/**
 * @author r.mohammadi
 */

public mixin class NavigationMixin {
   protected var selectedIndex : Integer;
   protected var ey : Number;

   public function doScroll(screenSize : Number, maxY : Number, minY : Number) : Void{

        var toY:Number;
        if(maxY > screenSize){
               toY = ey + (screenSize - maxY);
               println("Do scroll From: Ey {ey} maxY: {maxY} with {toY} To{ey + toY}");
            }
                else if(minY < 0){
                    toY = ey - (0 + (minY - 25));
                }
            Timeline {
                keyFrames : [
                    KeyFrame {
                        time : 500ms
                        canSkip : true
                        values: [ey => toY tween Interpolator.EASEBOTH]
                        action:function():Void{
//                            if(currentScreen == 1) {
//                                  updateSize();
//                            }
                        }
                    }
                ]
            }
            .playFromStart();
}

/*
 * Functions which are responsible for the navigation key actions
*/
//function onLeftSoftKey():Void{
//    if(Main.currentScreen == 1){
//            FX.exit();
//            println("Sluit");
//        }
//        else if(Main.currentScreen == 2){
//            Main.showScreen("photo", "album");
//            println("Go to Album Stack");
//        }
//        else if(Main.currentScreen == 3){
//            if(Main.SLIDE_SHOW.running == true){
//                Main.SLIDE_SHOW.stop();
//            }
//            Main.showScreen("full", "photo");
//
//            println("Go to Photo Stack");
//        }
//    }
public function onRightSoftKey():Void{
    selectedIndex ++;
    println("selectedIndex {selectedIndex}");
//    if(Main.currentScreen == 1){
//        if(selectedIndex == -1)then selectedIndex = 0;
//         Main.showScreen("album","home");
//        }
//        else if(Main.currentScreen == 2){
//            println("Toon foto in groot formaat");
//            Main.showFullPhoto(thumbRef[selectedPhoto].photo);
//        }
//        else if(Main.currentScreen == 3){
//            if(Main.SLIDE_SHOW.running == true){
//                Main.SLIDE_SHOW.stop();
//                Main.rightButton.text = "Play";
//            }
//            else {
//                SLIDE_SHOW.playFromStart();
//                rightButton.text = "Stop";
//            }
//        }
}

//function onLeftArrowKey():Void {
//    println("Pressed Left Key");
//      if (currentScreen == 2){
//         selectedPhoto --;//= ((sizeof thumbRef)/config.MAX_COLS);
//         println("Met links {selectedPhoto}");
//        }
//            else if (currentScreen == 3){
//                showPreviousPhoto();
//            }
//}
//function onRightArrowKey():Void {
//    println("Pressed Right Key");
//     if (currentScreen == 2){
//            selectedPhoto ++;//= ((sizeof thumbRef)/config.MAX_COLS);
//            println("Met rechts {selectedPhoto}");
//        }
//            else if (currentScreen == 3){
//                showNextPhoto();
//            }
//}
//function onUpArrowKey() :Void{
//    println("Pressed Up Key");
//    if (currentScreen == 1){
//        selectedAlbum --;
//    }
//        else if (currentScreen == 2){
//            if(selectedPhoto== -1) then selectedPhoto = 0 else selectedPhoto -= config.MAX_COLS;
//        }
//            else if (currentScreen == 3){
//                showPreviousPhoto();
//            }
//}
//function onDownArrowKey() :Void{
//    println("Pressed Down Key");
//    if (currentScreen == 1){
//        selectedAlbum ++;
//    }
//        else if (currentScreen == 2){
//            if(selectedPhoto== -1) then selectedPhoto = sizeof thumbRef else selectedPhoto += config.MAX_COLS;
//        }
//            else if (currentScreen == 3){
//                showNextPhoto();
//            }
//}
//function onEnterKey():Void{
//       if (currentScreen == 1){
//            if (selectedAlbum == -1){
//                selectedAlbum = 0
//            }
//            showScreen("album", "home");
//        }
//            else if (currentScreen == 2){
//                if (selectedPhoto == -1){
//                    selectedPhoto = 0
//                }
//                showFullPhoto(thumbRef[selectedPhoto].photo);
//            }
//            else if (currentScreen == 3 and orientationNormal == true){
//                buttonBarShown = not buttonBarShown;
//            }
//    }
}
